#include<bits/stdc++.h>
using namespace std;
//long long     !!!!
//freopen        !!!
// many tests      CLEAR   !!!!
int n,T,a[200010],maxn;
bitset<100> f;
void dfs(int d){
    if(d>n){
        int sum=0;
        for(int i=2;i<=n;i++){
            int pos=0;
            for(int j=i-1;j>=1;j--){
                if(f[i]==f[j]){
                    pos=j;break;
                }
            }
            if(pos&&a[pos]==a[i]) sum+=a[i]; 
        }maxn=max(maxn,sum);
        return;
    }
    dfs(d+1);
    f[d]=1;
    dfs(d+1);
    f[d]=0;
}
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout); 
    scanf("%d",&T);
    for(int I=1;I<=T;I++){
        scanf("%d",&n);
        for(int i=1;i<=n;i++){
            scanf("%d",&a[i]);
        }
        if(n<=100){
            maxn=0;
            f.reset();
            dfs(1);
            cout<<maxn<<"\n";
        }else{
            cout<<2333<<"\n";
        }
    }
    return 0;
}